package com.aixingfu.sports.Adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.aixingfu.sports.Model.SelectCardTypeModel;
import com.aixingfu.sports.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.vondear.rxtool.RxTimeTool;

import java.util.List;

/**
 * Author : lv
 * Time : 2019.04.30 0011
 * Description :
 */
public class SelectCardTypeAdapter extends BaseQuickAdapter<SelectCardTypeModel.DataBean.CardDataBean, BaseViewHolder> {

    private Context context;

    public SelectCardTypeAdapter(int layoutResId, @Nullable List<SelectCardTypeModel.DataBean.CardDataBean> data) {
        super(layoutResId, data);
    }

    public SelectCardTypeAdapter(Context context, int layoutResId, @Nullable List<SelectCardTypeModel.DataBean.CardDataBean> data) {
        super(layoutResId, data);

        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, SelectCardTypeModel.DataBean.CardDataBean item) {
        helper.addOnClickListener(R.id.tv_renew)
                .addOnClickListener(R.id.tv_upgrade)
        .setText(R.id.tv_member_code,"会员卡号："+item.getCard_number())
        .setText(R.id.tv_last_time,"到期时间："+RxTimeTool.stampToDate(item.getInvalid_time()))
        .setText(R.id.tv_start_time,"办卡日期："+RxTimeTool.stampToDate(item.getCreate_at()))
        .setText(R.id.tv_remarks,"备注："+item.getNote())
                .setText(R.id.tv_card_name,"卡名称："+item.getCard_name())
        .setText(R.id.tv_venue,"所属场馆："+item.getVennue_name())

                .setText(R.id.tv_leave_number,"已请假次数：" + item.getLeave_type())
        .setText(R.id.tv_card_price,"卡售价："+ item.getAmount_money())
        .setText(R.id.tv_activation_date,"激活日期："+ RxTimeTool.stampToDate(item.getActive_time()))
        .setText(R.id.tv_membership_consultant,"会籍顾问："+ item.getE_name())
        .setText(R.id.tv_transfer_number,"剩余转让次数：" + item.getTransfer_num());
        String status = item.getStatus();
        String usage_mode = item.getUsage_mode();
        if ("1".equals(status)){
            helper.setGone(R.id.ll_renew_upgrade,true);
            helper.setText(R.id.tv_card_state,"正常");
            helper.setBackgroundRes(R.id.tv_card_state,R.color.color1);
        }else if ("2".equals(status)){
            helper.setGone(R.id.ll_renew_upgrade,false);
            helper.setText(R.id.tv_card_state,"异常");
            helper.setBackgroundRes(R.id.tv_card_state,R.color.color2);
        }else if ("3".equals(status)){
            helper.setGone(R.id.ll_renew_upgrade,false);
            helper.setText(R.id.tv_card_state,"冻结");
            helper.setBackgroundRes(R.id.tv_card_state,R.color.color3);
        }else if ("4".equals(status)){
            helper.setGone(R.id.ll_renew_upgrade,true);
            helper.setText(R.id.tv_card_state,"未激活");
            helper.setBackgroundRes(R.id.tv_card_state,R.color.color1);
        }else if ("5".equals(status)){
            helper.setGone(R.id.ll_renew_upgrade,false);
            helper.setText(R.id.tv_card_state,"挂起");
            helper.setBackgroundRes(R.id.tv_card_state,R.color.color2);
        }else if ("6".equals(status)){
            helper.setGone(R.id.ll_renew_upgrade,false);
            helper.setText(R.id.tv_card_state,"已过期");
            helper.setBackgroundRes(R.id.tv_card_state,R.color.color2);
        }else if ("15".equals(status)){
            helper.setGone(R.id.ll_renew_upgrade,false);
            helper.setText(R.id.tv_card_state,"待审核");
            helper.setBackgroundRes(R.id.tv_card_state,R.color.color4);
        }else if ("16".equals(status)){
            helper.setGone(R.id.ll_renew_upgrade,false);
            helper.setText(R.id.tv_card_state,"未通过");
            helper.setBackgroundRes(R.id.tv_card_state,R.color.color3);
        }else if ("17".equals(status)){
            helper.setGone(R.id.ll_renew_upgrade,false);
            helper.setText(R.id.tv_card_state,"待审核");
            helper.setBackgroundRes(R.id.tv_card_state,R.color.color3);
        }
        if ("1".equals(usage_mode)){
            helper.setText(R.id.tv_usage_mode,"使用方式：" + "自用");
        }else if ("2".equals(usage_mode)){
            helper.setText(R.id.tv_usage_mode,"使用方式：" + "送人");
        }
//         .setText(R.id.tv_activation_date,"激活日期："+ RxTimeTool.stampToDate(item.getActive_time()))
        String active_time = RxTimeTool.stampToDate(item.getActive_time());
        if ("1970-01-01".equals(active_time)){
             helper.setText(R.id.tv_activation_date,"激活日期："+ "暂未激活");
        }else {
             helper.setText(R.id.tv_activation_date,"激活日期："+ RxTimeTool.stampToDate(item.getActive_time()));
        }

    }

}
